// JavaScript Document
function viewProfileRequest()
{
	$.post("admin/viewprofilerequest.php",function(data){
								   $('#entire').html(data);
								   });
}
function show_admin_inbox()
{
	$.post("inbox/show_inbox_admin.php",function(data){
							$('#entire').html(data);
										});
}
function Selected(len,deci)
{
	$('#notice').hide();
	var flag=0;
	var ids="";
	for(var i=1;i<=len;i++)
	{
		if($('#check'+i).is(':checked'))
		{
			flag++;
			ids+=$('#check'+i).val()+':';
		}
	}
	if(flag==0)
	{
		return false;
	}
	else
	{
		//update profile as rejected one
		ids=ids.slice(0,-1);
		$.post("admin/updateprofiledecision.php",{id:ids,decision:deci,length:flag},function(){
				$('#notice').html('Account updated Successfully').show().fadeOut(3000);
				viewProfileRequest();
																							 });
	}
}
function updateDetailedView(deci)
{
	$('#notice').hide();
	$.post("admin/updateprofiledecision.php",{id:$('#pro_id').val(),decision:deci},function(){
				$('#notice').html('Account updated Successfully').show().fadeOut(3000);
				viewProfileRequest();});
}
function viewProfile(p_id)
{
	$.post("admin/viewprofile.php",{id:p_id},function(data){
									$('#Innerheading').html('View Profile');
								   $('#InnerDarkbox').html(data);
								   });
}
function academicRequest()
{
	$.post("admin/acadmicreqview.php",{test:0,year:0},function(data){
						$('#entire').html(data);
						$('#Just_loading').ready(function(){
												getAcadResults();		  
														  })
								   });
}
function exCurrRequest()
{
	$.post("admin/extracurrreqview.php",{test:0,year:0},function(data){
						$('#entire').html(data);
						$('#Just_loading').ready(function(){
												getExtraResults();		  
														  })
								   });
}
function getAcadResults()
{
	$('#acad_loading').show();
	$.post("admin/get_academic_results.php",{test:$('#test').val(),year:$('#year').val()},function(data){
		$('#Just_loading').html(data);
		$('#acad_loading').hide();
	});
}
function induAcad(a_id,decs)
{
	$.post("admin/upinduacad.php",{id:a_id,decision:decs},function(){
	$('#notice').html('Points updated Successfully').show().fadeOut(3000);
			getAcadResults();
						  });
}
function selectedAcad(deci)
{
	var flag=0;
	var ids="";
	var len=$('#no_req').val();
	for(var i=1;i<=len;i++)
	{
		if($('#check'+i).is(':checked'))
		{
			flag++;
			ids+=$('#check'+i).val()+':';
		}
	}
	if(flag==0)
	{
		return false;
	}
	else
	{
		ids=ids.slice(0,-1);
		$.post("admin/upinduacad.php",{id:ids,decision:deci,length:flag},function(){
				$('#notice').html('Points updated Successfully').show().fadeOut(3000);
				getAcadResults();
		});
	}
}
function getExtraResults()
{
	$('#acad_loading').show();
	$.post("admin/get_extra_results.php",{test:$('#test').val(),year:$('#year').val()},function(data){
		$('#Just_loading').html(data);
		$('#acad_loading').hide();
	});
}

function induExtra(a_id,decs)
{
	$.post("admin/upinduextra.php",{id:a_id,decision:decs},function(){
	$('#notice').html('Points updated Successfully').show().fadeOut(3000);
			getExtraResults();
						  });
}
function selectedExtra(deci)
{
	var flag=0;
	var ids="";
	var len=$('#no_req').val();
	for(var i=1;i<=len;i++)
	{
		if($('#check'+i).is(':checked'))
		{
			flag++;
			ids+=$('#check'+i).val()+':';
		}
	}
	if(flag==0)
	{
		return false;
	}
	else
	{
		ids=ids.slice(0,-1);
		$.post("admin/upinduextra.php",{id:ids,decision:deci,length:flag},function(){
				$('#notice').html('Points updated Successfully').show().fadeOut(3000);
				getExtraResults();
		});
	}
}
function adduser()
{
	$.post("settings/adduser/add_user.php",function(select_role){
	if(select_role!="")
   	{
	   $('#entire').html(select_role);
   	}
  	});
}
function load_add_register_form()
{
	$.post("settings/adduser/register.php",function(register){
	$('#entire').html(register);
	});
	if($('#select_role').val()==1)
	{
		$.post("settings/adduser/student_form.php",function(student_form){
		$('#InnerDarkBox').html(student_form);
		$('#Innerheading').html('Add Student');
		});
	}
	else
	{
		$.post("settings/adduser/staff_form.php",function(staff_form){
		$('#InnerDarkBox').html(staff_form);
		$('#Innerheading').html('Add Staff');
		});
	}
}
function check_adduser(){
	$('#register_status').hide();
	if(checkUsername()==false)return false;
	$.post("register/checkavail.php",{username:$('#username').val()},function(data){
			if(data!="true")
			{
				$('#register_status').addClass('strykerError');
				$('#register_status').html('Userid already exists.').show().fadeOut(3000);
			}
			else
			{
				if(checkPassword()==false)return false;
				if(checkName()==false)return false;
				if(checkRoleDesgNo()==false)return false;
				Updateadduser();		
			}
	});
}
function Updateadduser(){
	$.post("settings/adduser/saveuser.php",{userid:$('#username').val(),password:$('#password').val(),role:$('#role').val(),name:$('#name').val(),regno:$('#regno').val(),commitee:$('#commitee').val(),year:$('#year').val(),house:$('#house').val(),email:$('#email').val(),desg:$('#desg').val()},function(use){
 if(use!="")
 {
	 	$.post("settings/adduser/add_user.php",function(data){
					$('#notice').html('New user added Sucessfully').show().fadeOut(6000);
						$('#entire').html(data);
										  });
 }
 else
 {
	 alert("Cannot update your account at this time");
 }
 });
}
function blockuser()
{
	$.post("settings/block/blockuser.php",function(data){$('#entire').html(data);});
}
function unblock(id)
{
	$.post("settings/block/unblock.php",{p_id:id,block:'notok'},function(data){
		$('#notice').html('Account unblocked Sucessfully').show().fadeOut(6000);
					blockuser();
					});
}
function selectblockuser()
{
	$.post("settings/block/selectblockuser.php",function(data){$('#InnerDarkbox').html(data);$('#Innerheading').html('Select User');});
}
function blockit(id)
{
	$.post("settings/block/unblock.php",{p_id:id,block:'ok'},function(data){
		$('#notice').html('Account Blocked Sucessfully').show().fadeOut(6000);
					blockuser();
					});
}

function editptsys()
{
	$.post("settings/pt_system/editptsys.php",function(data){
			$('#entire').html(data);
					   });
}
function assign_office()
{
	$.post("settings/assignoffb/assign.php",function(data){$('#entire').html(data);});
}
function admin_report()
{
	$.post("report/admin_report.php",function(data){$('#entire').html(data);});
}